/*
 * @Description:底部
 * @Author: iamsmiling
 * @Date: 2021-06-09 07:20:50
 * @LastEditTime: 2021-06-14 17:32:08
 */
import 'dart:ui';

import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/common_kit/color_kit.dart';
import 'package:credit_business_circle/components/dash_border/dash_border.dart';
import 'package:credit_business_circle/domain/local/partner/partner_commission_entity.dart';
import 'package:flutter/material.dart';

class StarPartnerFooter extends StatelessWidget {
  const StarPartnerFooter({Key? key}) : super(key: key);

  static PartnerCommissionEntity demo1 = PartnerCommissionEntity.sample1();
  static PartnerCommissionEntity demo2 = PartnerCommissionEntity.sample2();
  @override
  Widget build(BuildContext context) {
    return Container(
      color: R.color.ffffffff,
      width: R.dimen.width,
      padding: EdgeInsets.symmetric(horizontal: R.dimen.dp13),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            padding: EdgeInsets.only(top: R.dimen.dp27, bottom: R.dimen.dp16),
            child: Text(
              "佣金分配示例图",
              style: TextStyle(
                  fontSize: R.dimen.sp15,
                  color: R.color.ff111111,
                  fontWeight: FontWeight.w600),
            ),
          ),
          Container(
            margin: EdgeInsets.only(bottom: R.dimen.dp16),
            child: Text(
              "佣金分配制度以下级充值为例，箭头方向为各级推荐关系",
              style: TextStyle(
                  fontWeight: FontWeight.w500,
                  fontSize: R.dimen.sp14,
                  color: R.color.ffb76030),
            ),
          ),
          Container(
            margin: EdgeInsets.only(bottom: R.dimen.dp9),
            padding: EdgeInsets.symmetric(
                horizontal: R.dimen.dp12, vertical: R.dimen.dp5),
            decoration: BoxDecoration(
                color: R.color.fff2f2f2,
                borderRadius: BorderRadius.circular(R.dimen.sp3)),
            child: Text(
              "示例1",
              style: TextStyle(
                  fontWeight: FontWeight.w600,
                  fontSize: R.dimen.sp14,
                  color: R.color.ff0f8ae0),
            ),
          ),

          Row(
            children: [
              Container(
                child: Column(
                  children: [
                    for (PartnerEntity p in demo1.roles)
                      Container(
                        width: R.dimen.width * .35,
                        decoration: BoxDecoration(
                            border: Border(
                                right: BorderSide(
                                    width: 3,
                                    color: p == demo1.roles.last
                                        ? R.color.transparent
                                        : R.color.fffc5514))),
                        padding: EdgeInsets.only(
                            top: R.dimen.dp21,
                            bottom: R.dimen.dp21,
                            right: R.dimen.dp24),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.end,
                          children: [
                            Text(
                              p.role,
                              style: TextStyle(
                                  fontWeight: FontWeight.w600,
                                  fontSize: R.dimen.sp17,
                                  foreground: Paint()
                                    ..color = R.color.ff222222
                                    ..shader = LinearGradient(
                                            colors: p.roleColors
                                                .map((e) => ColorKit.fromHex(e))
                                                .toList())
                                        .createShader(Rect.fromLTWH(
                                            0, 0, R.dimen.dp70, R.dimen.dp18))),
                            ),
                            Visibility(
                              visible: p.relationShip.isNotEmpty,
                              child: Container(
                                margin: EdgeInsets.only(top: R.dimen.dp8),
                                child: Text(
                                  p.relationShip,
                                  style: TextStyle(
                                      fontSize: R.dimen.sp13,
                                      fontWeight: FontWeight.w500,
                                      color: R.color.ff666666),
                                ),
                              ),
                            )
                          ],
                        ),
                      )
                  ],
                ),
              ),
              Expanded(
                  child: Container(
                child: Column(
                  children: [
                    for (PartnerEntity p in demo1.roles)
                      Row(
                        children: [
                          if (p != demo1.roles.last)
                            Transform.translate(
                              offset: Offset(-R.dimen.dp7, 0),
                              child: Container(
                                width: R.dimen.dp11,
                                height: R.dimen.dp11,
                                decoration: BoxDecoration(
                                    borderRadius:
                                        BorderRadius.circular(R.dimen.sp5),
                                    gradient: LinearGradient(colors: [
                                      R.color.fffc5514,
                                      R.color.fffd861c
                                    ]),
                                    border: Border.all(
                                        color: R.color.ffffffff,
                                        width: R.dimen.dp2)),
                                margin: EdgeInsets.only(
                                  right: R.dimen.dp13,
                                ),
                              ),
                            )
                          else
                            Transform.translate(
                              offset: Offset(
                                  -(R.dimen.dp6 + R.dimen.dp13), -R.dimen.dp12),
                              child: Container(
                                  margin: EdgeInsets.only(left: R.dimen.dp13),
                                  child: Column(
                                    children: [
                                      Container(
                                        width: 3,
                                        color: R.color.fffc5514,
                                        height: R.dimen.dp32,
                                      ),
                                      Image.asset(R.image.downArrow),
                                    ],
                                  )),
                            ),
                          Container(
                            margin: EdgeInsets.only(
                                left: R.dimen.dp13,
                                top: R.dimen.dp21,
                                bottom: R.dimen.dp21),
                            constraints:
                                BoxConstraints(minWidth: R.dimen.dp169),
                            padding: EdgeInsets.only(
                                top: R.dimen.dp13,
                                bottom: R.dimen.dp13,
                                left: R.dimen.dp17),
                            decoration: BoxDecoration(
                                borderRadius:
                                    BorderRadius.circular(R.dimen.sp5),
                                color: R.color.fffef5db),
                            child: Row(
                              children: [
                                Text(
                                  p.description,
                                  style: TextStyle(
                                      fontSize: R.dimen.sp14,
                                      fontWeight: FontWeight.w600,
                                      color:
                                          ColorKit.fromHex(p.descriptionColor)),
                                ),
                                Visibility(
                                  child: Text.rich(
                                    TextSpan(text: "（", children: [
                                      TextSpan(
                                        text: "${p.fee}",
                                        style: TextStyle(
                                            fontSize: R.dimen.sp14,
                                            fontWeight: FontWeight.w600,
                                            color: R.color.fffd5b03),
                                      ),
                                      TextSpan(
                                        text: "）",
                                      )
                                    ]),
                                    style: TextStyle(
                                        fontSize: R.dimen.sp14,
                                        fontWeight: FontWeight.w600,
                                        color: ColorKit.fromHex(
                                            p.descriptionColor)),
                                  ),
                                  visible: p.fee.isNotEmpty,
                                )
                              ],
                            ),
                          ),
                        ],
                      )
                  ],
                ),
              ))
            ],
          ),

          Container(
            width: R.dimen.width,
            child: DashedRect(color: R.color.ffdddddd, gap: 3),
          ),
          Container(
            margin: EdgeInsets.only(bottom: R.dimen.dp9, top: R.dimen.dp26),
            padding: EdgeInsets.symmetric(
                horizontal: R.dimen.dp12, vertical: R.dimen.dp5),
            decoration: BoxDecoration(
                color: R.color.fff2f2f2,
                borderRadius: BorderRadius.circular(R.dimen.sp3)),
            child: Text(
              "示例2",
              style: TextStyle(
                  fontWeight: FontWeight.w600,
                  fontSize: R.dimen.sp14,
                  color: R.color.ff0f8ae0),
            ),
          ),

          Row(
            children: [
              Container(
                child: Column(
                  children: [
                    for (PartnerEntity p in demo2.roles)
                      Container(
                        width: R.dimen.width * .35,
                        decoration: BoxDecoration(
                            border: Border(
                                right: BorderSide(
                                    width: 3,
                                    color: p == demo2.roles.last
                                        ? R.color.transparent
                                        : R.color.fffc5514))),
                        padding: EdgeInsets.only(
                            top: R.dimen.dp21,
                            bottom: R.dimen.dp21,
                            right: R.dimen.dp24),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.end,
                          children: [
                            Text(
                              p.role,
                              style: TextStyle(
                                  fontWeight: FontWeight.w600,
                                  fontSize: R.dimen.sp17,
                                  foreground: Paint()
                                    ..color = R.color.ff222222
                                    ..shader = LinearGradient(
                                            colors: p.roleColors
                                                .map((e) => ColorKit.fromHex(e))
                                                .toList())
                                        .createShader(Rect.fromLTWH(
                                            0, 0, R.dimen.dp70, R.dimen.dp18))),
                            ),
                            Visibility(
                              visible: p.relationShip.isNotEmpty,
                              child: Container(
                                margin: EdgeInsets.only(top: R.dimen.dp8),
                                child: Text(
                                  p.relationShip,
                                  style: TextStyle(
                                      fontSize: R.dimen.sp13,
                                      fontWeight: FontWeight.w500,
                                      color: R.color.ff666666),
                                ),
                              ),
                            )
                          ],
                        ),
                      )
                  ],
                ),
              ),
              Expanded(
                  child: Container(
                child: Column(
                  children: [
                    for (PartnerEntity p in demo2.roles)
                      Row(
                        children: [
                          if (p != demo2.roles.last)
                            Transform.translate(
                              offset: Offset(-R.dimen.dp7, 0),
                              child: Container(
                                width: R.dimen.dp11,
                                height: R.dimen.dp11,
                                decoration: BoxDecoration(
                                    borderRadius:
                                        BorderRadius.circular(R.dimen.sp5),
                                    gradient: LinearGradient(colors: [
                                      R.color.fffc5514,
                                      R.color.fffd861c
                                    ]),
                                    border: Border.all(
                                        color: R.color.ffffffff,
                                        width: R.dimen.dp2)),
                                margin: EdgeInsets.only(
                                  right: R.dimen.dp13,
                                ),
                              ),
                            )
                          else
                            Transform.translate(
                              offset: Offset(
                                  -(R.dimen.dp6 + R.dimen.dp13), -R.dimen.dp12),
                              child: Container(
                                  margin: EdgeInsets.only(left: R.dimen.dp13),
                                  child: Column(
                                    children: [
                                      Container(
                                        width: 3,
                                        color: R.color.fffc5514,
                                        height: R.dimen.dp32,
                                      ),
                                      Image.asset(R.image.downArrow),
                                    ],
                                  )),
                            ),
                          Container(
                            margin: EdgeInsets.only(
                                left: R.dimen.dp13,
                                top: R.dimen.dp21,
                                bottom: R.dimen.dp21),
                            constraints:
                                BoxConstraints(minWidth: R.dimen.dp169),
                            padding: EdgeInsets.only(
                                top: R.dimen.dp13,
                                bottom: R.dimen.dp13,
                                left: R.dimen.dp17),
                            decoration: BoxDecoration(
                                borderRadius:
                                    BorderRadius.circular(R.dimen.sp5),
                                color: R.color.fffef5db),
                            child: Row(
                              children: [
                                Text(
                                  p.description,
                                  style: TextStyle(
                                      fontSize: R.dimen.sp14,
                                      fontWeight: FontWeight.w600,
                                      color:
                                          ColorKit.fromHex(p.descriptionColor)),
                                ),
                                Visibility(
                                  child: Text.rich(
                                    TextSpan(text: "（", children: [
                                      TextSpan(
                                        text: "${p.fee}",
                                        style: TextStyle(
                                            fontSize: R.dimen.sp14,
                                            fontWeight: FontWeight.w600,
                                            color: R.color.fffd5b03),
                                      ),
                                      TextSpan(
                                        text: "）",
                                      )
                                    ]),
                                    style: TextStyle(
                                        fontSize: R.dimen.sp14,
                                        fontWeight: FontWeight.w600,
                                        color: ColorKit.fromHex(
                                            p.descriptionColor)),
                                  ),
                                  visible: p.fee.isNotEmpty,
                                )
                              ],
                            ),
                          ),
                        ],
                      )
                  ],
                ),
              ))
            ],
          ),
          // LayoutBuilder(
          //     builder: (BuildContext context, BoxConstraints constraints) {
          //   print("最大高德1111");
          //   print(constraints.minHeight);
          //   return Column(
          //     children: [
          //       for (PartnerEntity p in demo1.roles)
          //         Container(
          //           child: Row(
          //             crossAxisAlignment: CrossAxisAlignment.center,
          //             children: [
          //               Expanded(
          //                 child: Container(
          //                   padding: EdgeInsets.only(
          //                       right: R.dimen.dp24, bottom: R.dimen.dp42),
          //                   decoration: BoxDecoration(
          //                       border: Border(
          //                           right: BorderSide(
          //                               width: 3, color: R.color.fffc5514))),
          //                   alignment: Alignment.centerRight,
          //                   child: Column(
          //                     crossAxisAlignment: CrossAxisAlignment.end,
          //                     mainAxisAlignment: MainAxisAlignment.center,
          //                     children: [
          //                       Text(
          //                         p.role,
          //                         style: TextStyle(
          //                             fontWeight: FontWeight.w600,
          //                             fontSize: R.dimen.sp17,
          //                             foreground: Paint()
          //                               ..color = R.color.ff222222
          //                               ..shader = LinearGradient(
          //                                       colors: p.roleColors
          //                                           .map((e) =>
          //                                               ColorKit.fromHex(e))
          //                                           .toList())
          //                                   .createShader(Rect.fromLTWH(0, 0,
          //                                       R.dimen.dp70, R.dimen.dp18))),
          //                       ),
          //                       Visibility(
          //                         visible: p.relationShip.isNotEmpty,
          //                         child: Container(
          //                           margin: EdgeInsets.only(top: R.dimen.dp8),
          //                           child: Text(
          //                             p.relationShip,
          //                             style: TextStyle(
          //                                 fontSize: R.dimen.sp13,
          //                                 fontWeight: FontWeight.w500,
          //                                 color: R.color.ff666666),
          //                           ),
          //                         ),
          //                       )
          //                     ],
          //                   ),
          //                 ),
          //               ),
          //               Expanded(
          //                 flex: 2,
          //                 child: Transform.translate(
          //                   offset: Offset(-R.dimen.dp7, 0),
          //                   child: Row(
          //                     children: [
          //                       p != demo1.roles.last
          //                           ? Container(
          //                               width: R.dimen.dp11,
          //                               height: R.dimen.dp11,
          //                               decoration: BoxDecoration(
          //                                   borderRadius: BorderRadius.circular(
          //                                       R.dimen.sp5),
          //                                   gradient: LinearGradient(colors: [
          //                                     R.color.fffc5514,
          //                                     R.color.fffd861c
          //                                   ]),
          //                                   border: Border.all(
          //                                       color: R.color.ffffffff,
          //                                       width: R.dimen.dp2)),
          //                               margin: EdgeInsets.only(
          //                                 right: R.dimen.dp13,
          //                               ),
          //                             )
          //                           : Image.asset(R.image.downArrow),
          //                       Container(
          //                         constraints:
          //                             BoxConstraints(minWidth: R.dimen.dp169),
          //                         padding: EdgeInsets.only(
          //                             top: R.dimen.dp13,
          //                             bottom: R.dimen.dp13,
          //                             left: R.dimen.dp17),
          //                         decoration: BoxDecoration(
          //                             borderRadius:
          //                                 BorderRadius.circular(R.dimen.sp5),
          //                             color: R.color.fffef5db),
          //                         child: Row(
          //                           children: [
          //                             Text(
          //                               p.description,
          //                               style: TextStyle(
          //                                   fontSize: R.dimen.sp14,
          //                                   fontWeight: FontWeight.w600,
          //                                   color: ColorKit.fromHex(
          //                                       p.descriptionColor)),
          //                             ),
          //                             Visibility(
          //                               child: Text.rich(
          //                                 TextSpan(text: "（", children: [
          //                                   TextSpan(
          //                                     text: "${p.fee}",
          //                                     style: TextStyle(
          //                                         fontSize: R.dimen.sp14,
          //                                         fontWeight: FontWeight.w600,
          //                                         color: R.color.fffd5b03),
          //                                   ),
          //                                   TextSpan(
          //                                     text: "）",
          //                                   )
          //                                 ]),
          //                                 style: TextStyle(
          //                                     fontSize: R.dimen.sp14,
          //                                     fontWeight: FontWeight.w600,
          //                                     color: ColorKit.fromHex(
          //                                         p.descriptionColor)),
          //                               ),
          //                               visible: p.fee.isNotEmpty,
          //                             )
          //                           ],
          //                         ),
          //                       ),
          //                     ],
          //                   ),
          //                 ),
          //               )
          //             ],
          //           ),
          //         )
          //     ],
          //   );
          // })
        ],
      ),
    );
  }
}
